{include file="header"}
<style type="text/css" media="all">
.dw {
	position: absolute;
	bottom: 20px;
	right: 0px;
	text-align: center;
	color: #FF5722;
}
.label-selected {
	width: 100%;
	min-height:38px;
	margin:10px 0;
	border:1px solid #ccc;
	background-color: #fff;
	position: relative;
}
.cell {
	display: block;
	width:90px;
	height:28px;
	line-height: 28px;
	border:3px;
	background:#009688;
	color:#fff;
	text-align: center;
}
.label-selected li {
	display: inline-block;
	height: 27px;
	line-height: 27px;
	font-size: .8rem;
	padding: 0 1rem;
	border: 1px solid #e6e6e6;
	border-radius: 2px;
	cursor: pointer;
	margin: 4px 2px;
	color: #666;
}
#labelItem {
	margin-bottom: 10px;
	display: none;
}
.label-item {
	border: 1px solid #e6e6e6;
	padding: 10px;
	border-radius: 0 2px 2px 0;
	position: relative;
	overflow: hidden;
	background: #fff;
}
.label-item li {
	display: inline-block;
	height: 27px;
	line-height: 27px;
	font-size: .8rem;
	padding: 0 1rem;
	border: 1px solid #e6e6e6;
	border-radius: 2px;
	cursor: pointer;
	margin-bottom: 5px;
	margin-left: 2px;
	color: #666;
}
.label-item .selected {
	color:#ccc;
}
.upfujian {
    border-radius: 1.25rem;
    position: absolute;
    top: 5px;
    right: 6px;
    height: 30px;
    line-height: 30px;
    width: 100px;
}
</style> 
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body" style="padding: 15px;">
        <!--表单提交-->
        {if get('id',0) == '0'}
        <form class="layui-form" url="{:url('admin/api/add')}" t_url="javascript:parent.location.reload();">
        {else /}
        <form class="layui-form" url="{:url('admin/api/edits')}" t_url="javascript:parent.location.reload();">
        <input type="hidden" name="id" value="{$c.id}">
        {/if}
        <input type="hidden" name="model" value="{:input('model')}">
        <div class="layui-row">
            <div class="layui-col-md4">
              <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                  <input type="radio" name="open" value="1" title="正常" {if $c.open == 1}checked=""{/if}>
                  <input type="radio" name="open" value="0" title="待审" {if $c.open == 0}checked=""{/if}>
                </div>
              </div>
            </div>
            <div class="layui-col-md3">
              <div class="layui-form-item">
                <label class="layui-form-label">置顶</label>
                <div class="layui-input-block">
                  <input type="radio" name="settop" value="1" title="打开" {if $c.settop == 1}checked=""{/if}>
                  <input type="radio" name="settop" value="0" title="关闭" {if $c.settop == 0}checked=""{/if}>
                </div>
              </div>
            </div>
        </div>
        <div class="layui-row">
            <div class="layui-col-md12">
                 <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                      <input type="text" name="title" lay-verify="required" value="{$c.title}"  autocomplete="off" placeholder="请输入" class="layui-input">
                    </div>
                 </div>
             </div>
        </div> 
        <div class="layui-row">
            {if fun_S('cate_m',array('tid'=>0,'m'=>input('model')),'px desc','1000',1)}
            <div class="layui-col-md3">
              <div class="layui-form-item">
                  <label class="layui-form-label">分类</label>
                  <div class="layui-input-block">
                     <select name="tid" lay-verify="required" >
                      <option value="">请选择分类</option>
                      {foreach name=":fun_S('cate_m',array('tid'=>0,'m'=>input('model')),'px desc','1000',1)" item="v" key="k"}
                     <option value="{$v.id}" {if $c.tid == $v.id}selected="选择"{/if}>{$v.name}</option>
                      {volist name=":fun_s('cate_m',array('tid'=>$v['id']),'px desc',100,1)" id="vo"}
                      <option value="{$vo.id}" {if $c.tid == $vo.id}selected="选择"{/if}>——{$vo.name}</option>
                      {/volist}  
                      {/foreach} 
                    </select>
                </div>
              </div>
            </div>
            {/if}
            <div class="layui-col-md3">
                 <div class="layui-form-item">
                    <label class="layui-form-label">用户UID</label>
                    <div class="layui-input-block">
                      <input type="number" name="uid" lay-verify="required" value="{:dingyi($c.uid,1)}"  autocomplete="off" class="layui-input">
                    </div>
                 </div>
             </div>
         </div>
        <!--配置 -->
        {foreach name=":json_model(fun_model(input('model'), 'config'))" item="v" key="k"}
        {if json_model_v($v,'admin')}
        <div class="layui-col-md{:json_model_v($v,'md')}">
            <div class="layui-form-item">
            <label class="layui-form-label">{:json_model_v($v,'title')}</label>
                <div class="layui-input-block">
                    {if json_model_v($v,'type')=='单选框'}
                    {volist name=":sku(json_model_v($v,'options'),PHP_EOL,',')" id="vo"}
                    <input type="radio" name="{:json_model_v($v,'zhiduan')}" value="{$vo.id}" title="{$vo.name}" {if $vo.id == dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}checked=""{/if} class="layui-input">
                    {/volist}
                    {/if}
                    {if json_model_v($v,'type')=='选择框'}
                    <select name="{:json_model_v($v,'zhiduan')}" lay-verify="{:json_model_v($v,'required')}">
                        <option value=""></option>
                        {volist name=":sku(json_model_v($v,'options'),PHP_EOL,',')" id="vo"}
                        <option value="{$vo.id}" {if $vo.id == dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}selected="selected"{/if}>{$vo.name}</option>
                        {/volist}
                    </select>
                    {/if}
                    {if json_model_v($v,'type')=='输入框'}
                    <input type="text" name="{:json_model_v($v,'zhiduan')}" value="{:dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}" placeholder="请输入内容" required  lay-verify="{:json_model_v($v,'required')}" autocomplete="off" class="layui-input">
                    {/if}
                    {if json_model_v($v,'type')=='密码框'}
                    <input type="password" name="{:json_model_v($v,'zhiduan')}" value="{:dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}" required  lay-verify="{:json_model_v($v,'required')}" autocomplete="off" class="layui-input">
                    {/if}
                    {if json_model_v($v,'type')=='文本域'}
                    <textarea name="{:json_model_v($v,'zhiduan')}" rows="{:dingyi(json_model_v($v,'rows'),6)}" placeholder="请输入内容" class="layui-textarea">{:dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}</textarea>
                    {/if}
                    {if json_model_v($v,'type')=='附件'}
                    <input type="text" name="{:json_model_v($v,'zhiduan')}" id="{$k}" value="{:dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}" required  lay-verify="{:json_model_v($v,'required')}" placeholder="可直接填写地址" autocomplete="off" class="layui-input">
                    <button type="button" class="layui-btn layui-btn-normal s{$k} upfujian">上传</button>
                    <script type="text/javascript">
                      layui.use(['form', 'upload', 'jquery']
                      ,function(){
                          var form = layui.form,
                          upload = layui.upload,
                          jq = layui.jquery;
                          upload.render({
                          elem: '.s{$k}',
                          url: "{:url("admin/up/up")}",
                          accept: 'file',
                          done: function(res) {
                              if (res.code == '1') {
                                jq('#{$k}').val(res.path);
                                if({$k}==0){
                                    $('input[name=size]').val(res.size)
                                }
                                return layer.msg(res.msg);
                              } else {
                                return layer.msg(res.msg);
                              }
                          }
                        });
                      });
                      </script>
                    {/if}
                    <!--1.01新增-->
                    {if json_model_v($v,'type')=='颜色'}
                    <input type="color" name="{:json_model_v($v,'zhiduan')}" value="{:dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}" placeholder="请选择颜色" class="layui-input" id="form-input{$k}" style="background-color: #F7F9FA; border: 2px solid #F7F9FA; border-radius: 1.25rem;height: 58px;">
                    {/if}
                    {if json_model_v($v,'type')=='时间'}
                    <input type="date" name="{:json_model_v($v,'zhiduan')}" value="{:dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}" placeholder="请选择时间" class="layui-input" id="form-input{$k}">
                    {/if}
                    {if json_model_v($v,'type')=='多选'}
                    <div class="label-selected label-{:json_model_v($v,'zhiduan')}">
                        <a href="javascript:;" class="layui-btn layui-btn-sm show-labelitem show-{:json_model_v($v,'zhiduan')}" style="float: right; margin: 4px; display: none; line-height: 30px;">展开</a>
                        <a href="javascript:;" class="layui-btn layui-btn-sm hide-labelitem hide-{:json_model_v($v,'zhiduan')}" style="float: right; margin: 4px; line-height: 30px;">收起</a>
                        <input type="hidden" value="{:dingyi($c[json_model_v($v,'zhiduan')],json_model_v($v,'value'))}" name="{:json_model_v($v,'zhiduan')}" nameid="{:json_model_v($v,'zhiduan')}">
                        {if $c[json_model_v($v,'zhiduan')]}
                        {volist name=":expz($c[json_model_v($v,'zhiduan')],',')" id="vo"} 
                        <li data="{$vo}">x {$vo}</li>
                        {/volist} 
                        {/if}
                    </div>
                    <div class="layui-col-md12 id-{:json_model_v($v,'zhiduan')}" id="labelItem" style="display: block;">
                        <div class="label-item label-item-{:json_model_v($v,'zhiduan')}">
                            {volist name=":sku(json_model_v($v,'options'),PHP_EOL,',')" id="vo"}
                            <li data="{$vo.name}" {if socha($c[json_model_v($v,'zhiduan')],$vo.name)==1}class="selected"{/if}><span>{$vo.name}</span></li>
                            {/volist}
                        </div> 
                    </div>
                    <script type="text/javascript">	
                    $(function(){
                      $(".show-{:json_model_v($v,'zhiduan')}").on("click",function(){
                        $(this).hide();
                        $(".hide-{:json_model_v($v,'zhiduan')}").show();
                        $(".id-{:json_model_v($v,'zhiduan')}").show();
                      });
                      $(".hide-labelitem").on("click",function(){
                        $(this).hide();
                        $(".show-labelitem").show();
                        $(".id-{:json_model_v($v,'zhiduan')}").hide();
                      });
                      $(".label-item-{:json_model_v($v,'zhiduan')}").on("click","li",function(){
                        var id = $(this).attr("data");
                        var text = $(this).children("span").html();
                        var labelHTML = "<li data='"+id+"''>x "+text+"</li>";
                        if($(this).hasClass("selected")){
                          return false;
                        }
                        $(".label-{:json_model_v($v,'zhiduan')}").append(labelHTML);
                        val = '';
                        for(var i = 0; i < $(".label-{:json_model_v($v,'zhiduan')}").children("li").length; i++){
                          val += $(".label-{:json_model_v($v,'zhiduan')}").children("li").eq(i).attr("data")+',';
                        }
                        $("input[nameid='{:json_model_v($v,'zhiduan')}']").val(val.substring(0,val.length-1));
                        $(this).addClass("selected");
                      });
                      var val = "";
                      $(".label-{:json_model_v($v,'zhiduan')}").on("click","li",function(){
                        var id = $(this).attr("data");
                        val = '';
                        $(this).remove();
                        for(var i = 0; i < $(".label-{:json_model_v($v,'zhiduan')}").children("li").length; i++){
                          val += $(".label-{:json_model_v($v,'zhiduan')}").children("li").eq(i).attr("data")+',';
                        }
                        $("input[nameid='{:json_model_v($v,'zhiduan')}']").val(val.substring(0,val.length-1));
                        $(".label-item-{:json_model_v($v,'zhiduan')}").find("li[data='"+id+"']").removeClass("selected");
                      });
                    })
                    </script>
                    {/if}
                </div>
            </div>
        </div>
        {/if}
        {/foreach}

        <!--配置end-->
        <div class="layui-form-item">
            <label for="L_title" class="layui-form-label">内容</label>
              <div class="layui-input-block">
                {include file="editor"} 
                {if 1==0} 
                <div style="border : 1px solid #cccccc;border-top: #ffffff;padding: 5px;">
                  <button type="button" id="fujianfgf" class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon">&#xe674;</i>附件分隔符</button>
                  <button type="button" id="scfujian" class="layui-btn layui-btn-sm layui-btn-normal" style="margin-right: 10px;"><i class="layui-icon">&#xe62f;</i>上传附件</button>
                  <button type="button" id="tianjialianjie" class="layui-btn layui-btn-sm layui-btn-normal"><i class="layui-icon">&#xe64c;</i>添加链接</button>
                  {if $c.id}
                  <button type="button" id="chongzhi" class="layui-btn layui-btn-sm layui-btn-normal" url="{:url('admin/api/cz',array('m'=>input('model'),'id'=>$c.id))}"><i class="layui-icon">&#xe669;</i>重置内容</button>
                  {/if}
                </div>
                {/if}
              </div>
          </div>
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn" lay-submit="" lay-filter="cms">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
<link rel="stylesheet" href="*ADMIN*/css/ir-black.css">
<script src="*ADMIN*/js/highlight.min.js"></script> 
<script >hljs.initHighlightingOnLoad();</script> 
  {include file="footer"}